package com.vecspace.dayu.code.ui.dao;

import java.util.List;
import org.springframework.stereotype.Repository;

import com.vecspace.database.dao.BaseDao;
import com.vecspace.dayu.code.ui.pojo.DataGrid;

/** DAYU-页面数据表格配置,操作数据库的dao类
 * @author: wanghua
 * @reviewer:
 * @template：wanghua
 */
@Repository("dayu_datagridDao")
public class DataGridDao extends BaseDao {
	/** 根据ID查询 DAYU-页面数据表格配置
	 * @param id   主键值
	 * @return DataGrid
	 * @throws Exception
	 * @author wanghua
	 */
	public DataGrid getDataGrid(Long id) throws Exception {
		DataGrid datagrid = null;
		if (id != null && id != 0) {

			datagrid = this.queryObject(DataGrid.class, id);
			this.evict(datagrid);
		}
		return datagrid;
	}
	
	/**获取功能下的表格/列表定义
	 * 
	 * @param funcId
	 * @return
	 * @throws Exception 
	 * @author wanghua
	 */
	public List<DataGrid> getDataGrids(Long funcId) throws Exception {
		List<DataGrid> datagrids = this.queryObjectList("from DataGrid where funcId=?0 order by ordnum", new Object[] {funcId});
		return datagrids;
	}
	
	
	public DataGrid getDataGridByTableIdAndTerminalType(Long tableId, String terminalType) throws Exception {
		DataGrid datagrid = this.queryObject("from DataGrid where tableId=?0 and platformType=?1", new Object[] {tableId, terminalType});
		return datagrid;
	}

	/** 插入或修改 DAYU-页面数据表格配置 
	 * @param item	要保存的对象
	 * @return void
	 * @throws Exception
	 * @author wanghua
	 */
	public void saveDataGrid(DataGrid item) throws Exception {
		this.saveOrUpdateObject(item);
	}

	/** 根据ID删除 DAYU-页面数据表格配置 
	 * @param id	主键值
	 * @return void
	 * @throws Exception
	 * @author wanghua
	 */
	public void deleteDataGrid(Long id) throws Exception {
		if (id != null && id != 0) {
			this.deleteObject(DataGrid.class, id);
		}
	}
}
